<template>
  <InlineLayout title-name="原始缴费明细列表">
    <template #header>
      <my-form ref="queryFormRef" v-model:modelValue="queryParams" :model="queryParams" :items-datas="itemsDatas">
        <my-button type="reset" title="重置" @click="resetQuery" />
        <my-button type="search" title="查询" :loading="loading" @click="handleQuery" />
      </my-form>
    </template>

    <!-- <template #titleTools>
        <my-button type="add" title="新增缴费" @click="handleAdd" />
        <my-button type="export" title="缴费导出" @click="handleExport" />
      </template> -->

    <my-table :columns="columns" :table-data="tableData" @selection-change="handleSelectionChange">
      <template #operation="scope">
        <my-button type="text" @click="handleDetail(scope.row)">详情</my-button>
      </template>
    </my-table>
    <template #footer>
      <pagination v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
    </template>
  </InlineLayout>
  <addOrEdit v-model="dialog.visible" :dialog-title="dialog.title" :current-row="currentRow" />
</template>

<script setup name="Ab04" lang="ts">
import { listAb04 } from '@/api/yuanshidian/ab04';
import { Ab04VO, Ab04Query, Ab04Form } from '@/api/yuanshidian/ab04/types';
import { getToken } from '@/utils/auth';
import addOrEdit from '@/views/yuanshidian/ab04/components/addOrEdit.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;

const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);
const currentRow = ref({});

const queryFormRef = ref<ElFormInstance>();

const dialog = reactive<DialogOption>({
  visible: false,
  auditIsShow: false,
  title: ''
});

const state = reactive({
  itemsDatas: [
    { label: '单位编码', prop: 'dw01', type: 'input' },
    { label: '单位名称', prop: 'dw02', type: 'input' },
    { label: '姓名', prop: 'gr04', type: 'input' },
    { label: '个人账号', prop: 'gr03', type: 'input' }
  ],
  tableData: [],
  columns: [
    { label: '序号', type: 'index', width: '55', prop: 'index' },
    { label: '统筹区编码', prop: 'aaa027', align: 'center', width: '100' },
    { label: '单位编码', prop: 'dw01', align: 'center', width: '90' },
    /*{ label: '单位名称', prop: 'dw02', align: 'center', width: '160' },*/
    { label: '姓名', prop: 'gr04', align: 'center', width: '90' },
    { label: '个人账号', prop: 'gr03', align: 'center', width: '150' },
    /*{ label: '身份证号码', prop: 'gr02', align: 'center', width: '150' },*/
    { label: '缴费时间', prop: 'grmx03', align: 'center', width: '150' },
    { label: '缴费月度', prop: 'grmx02', align: 'center', width: '90' },
    { label: '上年工资', prop: 'gr18', align: 'center', width: '80' },
    { label: '个人缴费基数', prop: 'gr19', align: 'center', width: '150' },
    { label: '个人缴费额', prop: 'gr20', align: 'center', width: '90' },
    { label: '单位划转额', prop: 'grmx04', align: 'center', width: '100' },
    { label: '单位代缴额', prop: 'grmx05', align: 'center', width: '100' },
    { label: '单位平均工资', prop: 'dw14', align: 'center', width: '110' },
    { label: '单位缴费比率', prop: 'cs03', align: 'center', width: '110' },
    { label: '计息年度', prop: 'grjx01', align: 'center', width: '80' },
    { label: '操作', type: 'operation', width: '80px' }
  ],
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    delStatus: 0
  }
});
const { itemsDatas, tableData, columns, queryParams } = toRefs(state);
/** 查询原人员账户明细(缴费明细)列表 */
const getList = async () => {
  loading.value = true;
  const res = await listAb04(queryParams.value);
  tableData.value = res.rows;
  total.value = res.total;
  loading.value = false;
};

/** 表单重置 */
const reset = () => {
  ab04FormRef.value?.resetFields();
};

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
};
/** 查看详情 */
const handleDetail = (row) => {
  currentRow.value.id = row.id;
  currentRow.value.type = 'detail';
  dialog.title = '查看原单位信息';
  dialog.visible = true;
};
onMounted(() => {
  getList();
});
</script>
